package com.developmentReformProject.vo;

import com.developmentReformProject.enums.HttpStatusEnum;

/**
 * 封装控制器响应数据
 * @author 胡志鹏
 * @param <T>
 */
public class ResultVo<T> {
    /**
     * 响应编号
     */
    private Integer code;
    /**
     * 响应消息
     */
    private String msg;
    /**
     * 响应的数据
     */
    private T data;

    public ResultVo(){
        this.code=HttpStatusEnum.SUCCESS.getValue();
        this.msg= HttpStatusEnum.SUCCESS.getDescription();
    }
    public ResultVo(T data){
        if(data==null){
            this.code=HttpStatusEnum.NOTFOUND.getValue();
            this.msg=HttpStatusEnum.NOTFOUND.getDescription();
        }else{
            this.code=HttpStatusEnum.SUCCESS.getValue();
            this.msg=HttpStatusEnum.SUCCESS.getDescription();
            this.data=data;
        }

    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
